#pragma once

#include "BaseEntity.h"
#include "SFML/Graphics.hpp"
#include "GameGlobals.h"
#include "PhysicsObject.h"

class BaseMoveable : public BaseEntity
{
private:
	sf::Vector2<float> Velocity;
	PhysicsObject* PhysObj;
protected:
	float AngularVelocity;
public:
	BaseMoveable(sf::RenderWindow *App);
	~BaseMoveable(void);

	PhysicsObject* GetPhysicsObject() {return PhysObj;};
	void CreatePhysics();

	virtual void OnCollide(BaseMoveable *ent1, BaseMoveable *ent2, CollisionData CollideInfo) {};
	virtual bool ShouldCollide(BaseMoveable *other) {return true;}; //Always collide by default

	void Tick();

	void SetVelocity(sf::Vector2f Vel)
	{ 
		if (PhysicsEnabled)
			PhysObj->SetVelocity(Vel);
		Velocity = Vel;
	};
	void SetVelocity(float x, float y)
	{ 
		if (PhysicsEnabled)
			PhysObj->SetVelocity(sf::Vector2f(x,y));
		Velocity.x = x; Velocity.y = y;
	};
	void AddVelocity(sf::Vector2f Vel)
	{
		if (PhysicsEnabled)
			PhysObj->SetVelocity(Vel + GetVelocity()); 
		Velocity += Vel;
	};

	sf::Vector2f GetVelocity() {return Velocity;};

	void SetAngularVel(float angvel) {AngularVelocity = angvel;};
	float GetAngularVel() {return AngularVelocity;};
};

